﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes {
    import flash.geom.*;
    import Classes.LogicComponents.*;
    import Modules.ships.cruise.*;
    import Modules.stats.types.*;

    public class HarvestableShip extends HarvestableResource {

        public static const COMPONENTS:Object = {cruise:CruiseShipLogicComponent};
        public static const DEFAULT_HARVESTABLE_SHIP_IMAGE:String = "grown";

        private const HARVESTABLE_SHIP:String = "harvestableShip";

        protected var m_logic:HarvestableShipComponentBase = null;

        public function HarvestableShip(_arg1:String){
            super(_arg1);
            setState(STATE_PLANTED);
            if (this.m_logic == null){
                this.m_logic = this.getLogicComponent();
            };
            m_objectType = WorldObjectTypes.HARVESTABLE_SHIP;
            m_typeName = this.HARVESTABLE_SHIP;
        }
        override public function setItem(_arg1:Item):void{
            super.setItem(_arg1);
            if (this.m_logic == null){
                this.m_logic = this.getLogicComponent();
            };
        }
        override public function get isHighlightable():Boolean{
            return (((super.isHighlightable) && (((!((m_state == STATE_PLANTED))) || (Global.world.isEditMode)))));
        }
        override protected function statsInit():void{
            super.statsInit();
            registerStatsActionName(TrackedActionType.HARVEST, "collect");
        }
        public function getLogicComponent():HarvestableShipComponentBase{
            var _local1:Class;
            var _local2:HarvestableShipComponentBase;
            if (COMPONENTS.hasOwnProperty(m_item.behavior)){
                _local1 = COMPONENTS[m_item.behavior];
                _local2 = (new _local1(this) as HarvestableShipComponentBase);
                return (_local2);
            };
            return (new HarvestableShipComponentBase(this));
        }
        override public function getToolTipStatus():String{
            return (this.m_logic.getToolTipStatus());
        }
        override public function getToolTipAction():String{
            return (this.m_logic.getToolTipAction());
        }
        override public function onPlayAction():void{
            if (m_visitReplayLock > 0){
                return;
            };
            super.onPlayAction();
            this.m_logic.handlePlayAction();
        }
        override public function getProgressBarCancelFunction():Function{
            var _local1:Function = this.m_logic.getProgressBarCancelFunction();
            return (((_local1)!=null) ? _local1 : super.getProgressBarCancelFunction());
        }
        override public function getProgressBarStartFunction():Function{
            var _local1:Function = this.m_logic.getProgressBarStartFunction();
            return (((_local1)!=null) ? _local1 : super.getProgressBarStartFunction());
        }
        override public function getProgressBarEndFunction():Function{
            var _local1:Function = this.m_logic.getProgressBarEndFunction();
            return (((_local1)!=null) ? _local1 : super.getProgressBarEndFunction());
        }
        override protected function createStagePickEffect():void{
            this.m_logic.createStagePickEffect();
        }
        override protected function updateArrow():void{
            if (this.m_logic.enableUpdateArrow()){
                this.createStagePickEffect();
            } else {
                removeStagePickEffect();
            };
        }
        override public function onUpdate(_arg1:Number):void{
            super.onUpdate(_arg1);
            this.m_logic.onUpdate(_arg1);
        }
        override protected function updateState(_arg1:Number):Boolean{
            return (this.m_logic.updateState(_arg1));
        }
        override public function harvest():Boolean{
            return (this.m_logic.harvest());
        }
        public function doDoobers():void{
            m_doobersArray = this.makeDoobers();
            spawnDoobers();
        }
        override protected function makeDoobers(_arg1:Number=1):Array{
            return (this.m_logic.makeDoobers(harvestingDefinition, m_secureRands, _arg1));
        }
        override public function doHarvestDropOff(_arg1:Boolean=true):Object{
            if (_arg1){
                displayDelayedResourceChanges();
            };
            return (super.doHarvestDropOff(_arg1));
        }
        override public function getHarvestTime():Number{
            return (this.m_logic.getHarvestTime());
        }
        override public function checkPlacementRequirements(_arg1:int, _arg2:int):Boolean{
            if (!super.checkPlacementRequirements(_arg1, _arg2)){
                return (false);
            };
            return (this.m_logic.checkPlacementRequirements(_arg1, _arg2));
        }
        override public function isHarvestable():Boolean{
            return (this.m_logic.isHarvestable());
        }
        override public function isPixelInside(_arg1:Point):Boolean{
            var _local2:Point;
            if (m_state == STATE_PLANTED){
                if (m_maskBitmap){
                    _local2 = _arg1.subtract(new Point(m_displayObject.x, m_displayObject.y));
                    _local2.x = (_local2.x / m_displayObject.scaleX);
                    _local2.y = (_local2.y / m_displayObject.scaleY);
                    _local2.x = (_local2.x - m_content.x);
                    _local2.y = (_local2.y - m_content.y);
                    if (m_maskBitmap.bitmapData.hitTest(new Point(0, 0), 0, _local2)){
                        return (true);
                    };
                };
            };
            return (super.isPixelInside(_arg1));
        }
        override protected function onStateChanged(_arg1:String, _arg2:String):void{
            super.onStateChanged(_arg1, _arg2);
            this.m_logic.onStateChanged(_arg1, _arg2);
        }
        override public function getActionText():String{
            return (this.m_logic.getActionText());
        }
        public function setPlantedWhenShipArrives():void{
            this.m_logic.setPlantedWhenShipArrives();
        }
        override public function isSellable():Boolean{
            return (this.m_logic.isSellable());
        }

    }
}//package Classes 
